home *** CD-ROM | disk | FTP | other *** search
- %BEGIN Ovals
-
- % Copyright (C) 1993 David John Burrowes
- % Distributed under terms of GNU General Public License.
- % See COPYING.text in Convert PICT's CommentedPSCode for a copy
-
- %%%%%%%%%%%%%
- % Note:
- % setupForArcPath, penWidth and penHeight defined in Common file
- %%%%%%%%%%%%%
-
- %%%%%%%%%%%%%
- % Name: ovalpath
- % Syntax: top left bottom right ovalpath -
- % About: Given the coordinates for a rectangle, builds an oval.
- % Note: this uses and sets the last* global values.
- %%%%%%%%%%%%%
- /ovalpath
- {
- /lastright exch def
- /lastbottom exch def
- /lastleft exch def
- /lasttop exch def
-
- newpath
- lastright lastleft sub % compute width & height
- lastbottom lasttop sub
- lastbottom lastleft setupForArcPath
- 0 360 arc
- closepath
- } def
-
-
- %%%%%%%%%%%%%
- % Name: frameOval [0050]
- % Syntax: top left bottom right start-angle stop-angle frameArc -
- % About: Use coords of a rectangle, this frames (outlines) the shape of
- % an oval from it, using the current penWidth and penHeight.
- % If the penwidth and height are both 1, then we do a special case
- % framing, because it looks a bit better, and will doubtlessly be
- % used frequently. Otherwise, we use the setupForArcPath routine to
- % build the path of an oval, and then build the path of one inside it.
- % The inner one is inset by the penWidth & Height values, and produces
- % the effect of the oval drawn with a pen of that size.
- % Note that the last* values are modified and used here
- %%%%%%%%%%%%%
- /frameOval
- {
- /lastright exch def
- /lastbottom exch def
- /lastleft exch def
- /lasttop exch def
-
- gsave
- penPattern usePattern
-
- /thewidth lastright lastleft sub def
- /theheight lastbottom lasttop sub def
- %
- % special case for pens that are 1 by 1 pixel
- %
- penHeight 1 eq
- penWidth 1 eq
- and
- {
- newpath
- thewidth theheight lastbottom lastleft setupForArcPath
- 0 360 arc
- closepath
- stroke
- }
- {
- %
- % More general case for penwidths and heights != 1
- %
- penHeight 0 gt % don't draw with a 0 sized pen.
- penWidth 0 gt
- and
- {
- /startmatrix matrix currentmatrix def
- newpath
- thewidth theheight lastbottom lastleft setupForArcPath
- 0 360 arc
- closepath
- %
- % Recover from distortions setupForArcPath did.
- % Calculate inner oval of the framed shape.
- %
- startmatrix setmatrix
-
- /innerRight lastright penWidth sub 1 add def
- /innerTop lasttop penHeight add 1 sub def
- /innerLeft lastleft penWidth add 1 sub def
- /innerBottom lastbottom penHeight sub 1 add def
- /innerWidth innerRight innerLeft sub def
- /innerHeight innerBottom innerTop sub def
-
- innerWidth innerHeight innerBottom innerLeft
- setupForArcPath
- 360 0 arcn
- closepath
- fill
- }
- if
- }
- ifelse
- grestore
- } def
-
- %%%%%%%%%%%%%
- % Name: paintOval [0051]
- % Syntax: t l b r paintOval -
- % About: pass parameters to ovalpath, and fill the resulting oval.
- %%%%%%%%%%%%%
- /paintOval
- {
- gsave
- penPattern usePattern
- ovalpath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: eraseOval [0052]
- % Syntax: t l b r eraseOval -
- % About: pass parameters to ovalpath, and erase the resulting oval.
- %%%%%%%%%%%%%
- /eraseOval
- {
- gsave
- backPattern usePattern
- ovalpath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: invertOval [0053]
- % Syntax: t l b r invertOval -
- % About: We can't duplicate the invert effect, so we just call ovalpath
- % to consume the parameters and set last* values.
- %%%%%%%%%%%%%
- /invertOval
- {
- gsave
- ovalpath
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: fillOval [0054]
- % Syntax: t l b r fillOval -
- % About: Use the arguments to build an oval path which we then fill
- %%%%%%%%%%%%%
- /fillOval
- {
- gsave
- fillPattern usePattern
- ovalpath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: frameSameOval [0058]
- % Syntax: - frameSameOval -
- % About: Using the last* values, frame an oval
- %%%%%%%%%%%%%
- /frameSameOval
- { lasttop lastleft lastbottom lastright frameOval }
- def
-
- %%%%%%%%%%%%%
- % Name: paintSameOval [0059]
- % Syntax: - paintSameOval -
- % About: Using the last* values, paint an oval
- %%%%%%%%%%%%%
- /paintSameOval
- { lasttop lastleft lastbottom lastright paintOval }
- def
-
- %%%%%%%%%%%%%
- % Name: eraseSameOval [005A]
- % Syntax: - eraseSameOval -
- % About: Using the last* values, erase an oval
- %%%%%%%%%%%%%
- /eraseSameOval
- { lasttop lastleft lastbottom lastright eraseOval }
- def
-
- %%%%%%%%%%%%%
- % Name: invertSameOval [005B]
- % Syntax: - invertSameOval -
- % About: Using the last* values, invert an oval
- %%%%%%%%%%%%%
- /invertSameOval
- { lasttop lastleft lastbottom lastright invertOval }
- def
-
- %%%%%%%%%%%%%
- % Name: fillSameOval [005C]
- % Syntax: - fillSameOval -
- % About: Using the last* values, fill an oval
- %%%%%%%%%%%%%
- /fillSameOval
- { lasttop lastleft lastbottom lastright fillOval }
- def
-
- %END Ovals
-